// pages/demanddetail/demand.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scrollHeight:800,
    list:[],
    id:'',
    totalYunFeeList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    var id = options.id
    var height =  app.globalData.windowHeight;
    this.setData({
      scrollHeight: height,
    })
    
    app.request.postHeadForm('hgz/dict/queryDictAndSubById/4').then(res =>{
      this.setData({
        totalYunFeeList:res.data.children
      })
      this.getData(id);
    })
    
  },
  getData(id){
    app.request.postHeadForm('hgz/demand/queryPriceById/' + id)
      .then(res => {
        var tabList = res.data;
        var totalYunFeeList = this.data.totalYunFeeList;
        if(tabList.length!=0){
          for(var i=0;i<totalYunFeeList.length;i++){
            if(tabList[0].brand == totalYunFeeList[i].dictValue){
                for(var j=0;j<tabList.length;j++){
                    // tabList[j].areaName;
                    var yunFee = 0;
                    if(totalYunFeeList[i].children!=null){
                        for(var k=0;k<totalYunFeeList[i].children.length;k++){
                            if(tabList[j].areaName == totalYunFeeList[i].children[k].dictName){
                              yunFee = totalYunFeeList[i].children[k].dictValue;
                              break;
                            }
                        }
                    }
                    console.log(yunFee);
                    tabList[j].price = tabList[j].price+Number(yunFee);
                }
                break;
            }
          }
        }
        this.setData({
          list: tabList
        })
      })
  }

})